import Vue from 'vue'
import App from './App.vue'
import router from './router'
import './plugins/element.js'
import './assets/styles/base.css'
import './assets/fonts/iconfont.css'
import axios from 'axios'
import ZkTable from 'vue-table-with-tree-grid'
import VueQuillEditor from 'vue-quill-editor'
import 'quill/dist/quill.core.css'
import 'quill/dist/quill.snow.css'
import 'quill/dist/quill.bubble.css'
import _ from 'lodash'
import NProgress from 'nprogress'
import 'nprogress/nprogress.css'

Vue.component(ZkTable.name, ZkTable)
Vue.use(VueQuillEditor)

axios.interceptors.request.use(function (config) {
  NProgress.start()
  config.headers.Authorization = sessionStorage.getItem('token') || ''

  return config
})
axios.interceptors.response.use(function (response) {
  NProgress.done()
  return response
})

axios.defaults.baseURL = 'https://www.liulongbin.top:8888/api/private/v1/'
Vue.prototype.$http = axios
Vue.config.productionTip = false

Vue.filter('dateFormat', function(info){
  let date = new Date(info)

  let y = date.getFullYear()
  let M = (date.getMonth() + 1 + '').padStart(2, '0')
  let d = (date.getDate() + '').padStart(2, '0')
  let h = (date.getHours() + '').padStart(2, '0')
  let m = (date.getMinutes() + '').padStart(2, '0')
  let s = (date.getSeconds() + '').padStart(2, '0')

  return `${y}-${M}-${d} ${h}:${m}:${s}`
})

new Vue({
  router,
  render: h => h(App),
  el: '#app'
})
